package problema030;

public class DigitFifthPowers {
	
	public static void main(String[] args){
		fifthPowers();
	}

	public static void fifthPowers(){
		long act = 0, suma = 0, ultima = 0, res = 0;
		for(int i = 2; i < 10000000; i++){
			act = i;
			while(act != 0){
				ultima = act % 10;
				suma += ultima * ultima * ultima * ultima * ultima;
				act = (act - ultima) / 10;
			}
			if(suma == i) res += suma;
			suma = 0;
		}
		System.out.println(res);
	}
}
